使用PerfView监测.NET程序性能(二):Perfview的使用

您所在的位置:网站首页 linux traceevent 使用PerfView监测.NET程序性能(二):Perfview的使用

使用PerfView监测.NET程序性能(二):Perfview的使用

#使用PerfView监测.NET程序性能(二):Perfview的使用| 来源: 网络整理| 查看: 265

在上一篇博客中,我们了解了对Windows及应用程序进行性能分析的基础:Event Trace for Windows (ETW)。现在来看看基于ETW的性能分析工具——Perfview.exe

Perfview简介

Perfview是一个开源的CPU和内存性能分析工具,也包括一些针对.NET的分析功能,例如GC分析,JIT分析,甚至ASP.NET中的请求统计等等。Perfview是一个Windows应用程序,但也能对在Linux系统上采集的数据进行分析(参考)。Perfview免安装,而且只是一个14M的.exe文件,非常容易部署到需要进行性能分析的机器上,例如生产环境的服务器。而且在性能数据收集的过程中不需要重启应用程序或者服务器,而且收集的性能数据日志(.etl文件)可以被拷贝到其他Windows机器上,再进行分析工作,对业务的影响非常少。

Perfview已迁移到GitHub上,可以在上面下载Perfview.exe,clone库或者查看相关资料。

Perfview GitHub:https://github.com/Microsoft/perfview

Perfview视频教程:https://channel9.msdn.com/Series/PerfView-Tutorial

Vance Morrison关于Perfview的博客:https://blogs.msdn.microsoft.com/vancem/tag/perfview/

 

 Perfview使用

在简单介绍Perfview后,我们来使用Perfview进行一个小小的性能分析,来熟悉一下Perfivew的基本操作。

这个实验使用的代码,就是Vance Morrison在视频教程中用到的Console程序。代码可以在Perfivew自带的帮助文件中找到。

using System; // using System.Collections.Generic; class Program { public static int aStatic = 0; // Spin is a simple compute bound program that lasts for 5 seconds // It is a useful test program for CPU profilers. static int Main(string[] args) { int numSec = 5; if (args.Length == 1) numSec = int.Parse(args[0]); Console.WriteLine("Spinning for {0} seconds", numSec); RecSpin(numSec); return 0; } // Spin for 'timeSec' seconds. We do only 1 second in this // method, doing the rest in the helper. static void RecSpin(int timeSec) { if (timeSec


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3